import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from common.base_page import BasePage
from utils.log_util import logger


class editpage(BasePage):
    _input_username = (By.ID, "username")
    _input_accid = (By.CSS_SELECTOR, "#memberAdd_acctid")
    _input_phone = (By.CSS_SELECTOR, "#memberAdd_phone")
    _save_button = (By.CSS_SELECTOR, ".qui_btn.ww_btn.js_btn_save")

    def edit_emp(self, username, accid, mobile):
        with allure.step("编辑成员信息"):
            """编辑成员信息"""
            logger.info("填写成员信息")
            self.wait_until(expected_conditions.element_to_be_clickable(self._input_username))
            self.find_ele(self._input_username).send_keys(username)
            self.find_ele(self._input_accid).send_keys(accid)
            self.find_ele(self._input_phone).send_keys(mobile)
            self.find_eles(self._save_button)[0].click()
            from page.emplist_page import EmplistPage
            return EmplistPage(self.driver)
